    <div class="refentry" id="glCopyBufferSubData">
      <div class="titlepage"></div>
      <div class="refnamediv">
        <h2>Name</h2>
        <p>glCopyBufferSubData, glCopyNamedBufferSubData — copy all or part of the data store of a buffer object to the data store of another buffer object</p>
      </div>
      <div class="refsynopsisdiv">
        <h2>C Specification</h2>
        <div class="funcsynopsis">
          <table style="border: 0; cellspacing: 0; cellpadding: 0;" class="funcprototype-table">
            <tr>
              <td>
                <code class="funcdef">void <strong class="fsfunc">glCopyBufferSubData</strong>(</code>
              </td>
              <td>GLenum <var class="pdparam">readTarget</var>, </td>
            </tr>
            <tr>
              <td> </td>
              <td>GLenum <var class="pdparam">writeTarget</var>, </td>
            </tr>
            <tr>
              <td> </td>
              <td>GLintptr <var class="pdparam">readOffset</var>, </td>
            </tr>
            <tr>
              <td> </td>
              <td>GLintptr <var class="pdparam">writeOffset</var>, </td>
            </tr>
            <tr>
              <td> </td>
              <td>GLsizeiptr <var class="pdparam">size</var><code>)</code>;</td>
            </tr>
          </table>
          <div class="funcprototype-spacer"> </div>
          <table style="border: 0; cellspacing: 0; cellpadding: 0;" class="funcprototype-table">
            <tr>
              <td>
                <code class="funcdef">void <strong class="fsfunc">glCopyNamedBufferSubData</strong>(</code>
              </td>
              <td>GLuint <var class="pdparam">readBuffer</var>, </td>
            </tr>
            <tr>
              <td> </td>
              <td>GLuint <var class="pdparam">writeBuffer</var>, </td>
            </tr>
            <tr>
              <td> </td>
              <td>GLintptr <var class="pdparam">readOffset</var>, </td>
            </tr>
            <tr>
              <td> </td>
              <td>GLintptr <var class="pdparam">writeOffset</var>, </td>
            </tr>
            <tr>
              <td> </td>
              <td>GLsizei <var class="pdparam">size</var><code>)</code>;</td>
            </tr>
          </table>
          <div class="funcprototype-spacer"> </div>
        </div>
      </div>
      <div class="refsect1" id="parameters">
        <h2>Parameters</h2>
        <div class="variablelist">
          <dl class="variablelist">
            <dt>
              <span class="term">
                <em class="parameter">
                  <code>readTarget</code>
                </em>
              </span>
            </dt>
            <dd>
              <p>
                    Specifies the target to which the source buffer object
                    is bound for <code class="function">glCopyBufferSubData</code>
                </p>
            </dd>
            <dt>
              <span class="term">
                <em class="parameter">
                  <code>writeTarget</code>
                </em>
              </span>
            </dt>
            <dd>
              <p>
                    Specifies the target to which the destination buffer
                    object is bound for
                    <code class="function">glCopyBufferSubData</code>.
                </p>
            </dd>
            <dt>
              <span class="term">
                <em class="parameter">
                  <code>readBuffer</code>
                </em>
              </span>
            </dt>
            <dd>
              <p>
                    Specifies the name of the source buffer object for
                    <code class="function">glCopyNamedBufferSubData</code>.
                </p>
            </dd>
            <dt>
              <span class="term">
                <em class="parameter">
                  <code>writeBuffer</code>
                </em>
              </span>
            </dt>
            <dd>
              <p>
                    Specifies the name of the destination buffer object for
                    <code class="function">glCopyNamedBufferSubData</code>.
                </p>
            </dd>
            <dt>
              <span class="term">
                <em class="parameter">
                  <code>readOffset</code>
                </em>
              </span>
            </dt>
            <dd>
              <p>
                    Specifies the offset, in basic machine units, within the
                    data store of the source buffer object at which data
                    will be read.
                </p>
            </dd>
            <dt>
              <span class="term">
                <em class="parameter">
                  <code>writeOffset</code>
                </em>
              </span>
            </dt>
            <dd>
              <p>
                    Specifies the offset, in basic machine units, within the
                    data store of the destination buffer object at which
                    data will be written.
                </p>
            </dd>
            <dt>
              <span class="term">
                <em class="parameter">
                  <code>size</code>
                </em>
              </span>
            </dt>
            <dd>
              <p>
                    Specifies the size, in basic machine units, of the data
                    to be copied from the source buffer object to the
                    destination buffer object.
                </p>
            </dd>
          </dl>
        </div>
      </div>
      <div class="refsect1" id="description">
        <h2>Description</h2>
        <p>
            <code class="function">glCopyBufferSubData</code> and
            <code class="function">glCopyNamedBufferSubData</code> copy part of the
            data store attached to a source buffer object to the data store
            attached to a destination buffer object. The number of basic
            machine units indicated by <em class="parameter"><code>size</code></em> is copied
            from the source at offset <em class="parameter"><code>readOffset</code></em> to
            the destination at <em class="parameter"><code>writeOffset</code></em>.
            <em class="parameter"><code>readOffset</code></em>,
            <em class="parameter"><code>writeOffset</code></em> and
            <em class="parameter"><code>size</code></em> are in terms of basic machine units.
        </p>
        <p>
            For <code class="function">glCopyBufferSubData</code>,
            <em class="parameter"><code>readTarget</code></em> and
            <em class="parameter"><code>writeTarget</code></em> specify the targets to which
            the source and destination buffer objects are bound, and must
            each be one of the buffer binding targets in the following
            table:
        </p>
        <div class="informaltable">
          <table style="border-collapse: collapse; border-top: 2px solid ; border-bottom: 2px solid ; border-left: 2px solid ; border-right: 2px solid ; ">
            <colgroup>
              <col style="text-align: left; " class="col1"/>
              <col style="text-align: left; " class="col2"/>
            </colgroup>
            <thead>
              <tr>
                <th style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <span class="bold">
                    <strong>Buffer Binding Target</strong>
                  </span>
                </th>
                <th style="text-align: left; border-bottom: 2px solid ; ">
                  <span class="bold">
                    <strong>Purpose</strong>
                  </span>
                </th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_ARRAY_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Vertex attributes</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_ATOMIC_COUNTER_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Atomic counter storage</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_COPY_READ_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Buffer copy source</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_COPY_WRITE_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Buffer copy destination</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_DISPATCH_INDIRECT_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Indirect compute dispatch commands</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_DRAW_INDIRECT_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Indirect command arguments</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_ELEMENT_ARRAY_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Vertex array indices</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_PIXEL_PACK_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Pixel read target</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_PIXEL_UNPACK_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Texture data source</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_QUERY_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Query result buffer</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_SHADER_STORAGE_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Read-write storage for shaders</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_TEXTURE_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Texture data buffer</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="constant">GL_TRANSFORM_FEEDBACK_BUFFER</code>
                </td>
                <td style="text-align: left; border-bottom: 2px solid ; ">Transform feedback buffer</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; ">
                  <code class="constant">GL_UNIFORM_BUFFER</code>
                </td>
                <td style="text-align: left; ">Uniform block storage</td>
              </tr>
            </tbody>
          </table>
        </div>
        <p>
            Any of these targets may be used, but the targets
            <code class="constant">GL_COPY_READ_BUFFER</code> and
            <code class="constant">GL_COPY_WRITE_BUFFER</code> are provided
            specifically to allow copies between buffers without disturbing
            other GL state.
        </p>
        <p>
            <em class="parameter"><code>readOffset</code></em>,
            <em class="parameter"><code>writeOffset</code></em> and
            <em class="parameter"><code>size</code></em> must all be greater than or equal to
            zero. Furthermore, $readOffset+size$ must not exceeed the size
            of the source buffer object, and $writeOffset+size$ must not
            exceeed the size of the buffer bound to
            <em class="parameter"><code>writeTarget</code></em>. If the source and
            destination are the same buffer object, then the source and
            destination ranges must not overlap.
        </p>
      </div>
      <div class="refsect1" id="notes">
        <h2>Notes</h2>
        <p>
            The <code class="constant">GL_DISPATCH_INDIRECT_BUFFER</code> and
            <code class="constant">GL_SHADER_STORAGE_BUFFER</code> targets are
            available only if the GL version is 4.3 or greater.
        </p>
        <p>
            The <code class="constant">GL_QUERY_BUFFER</code> target is available
            only if the GL version is 4.4 or greater.
        </p>
      </div>
      <div class="refsect1" id="errors">
        <h2>Errors</h2>
        <p>
            <code class="constant">GL_INVALID_ENUM</code> is generated by
            <code class="function">glCopyBufferSubData</code> if
            <em class="parameter"><code>readTarget</code></em> or
            <em class="parameter"><code>writeTarget</code></em> is not one of the buffer
            binding targets listed above.
        </p>
        <p>
            <code class="constant">GL_INVALID_OPERATION</code> is generated by
            <code class="function">glCopyBufferSubData</code> if zero is bound to
            <em class="parameter"><code>readTarget</code></em> or
            <em class="parameter"><code>writeTarget</code></em>.
        </p>
        <p>
            <code class="constant">GL_INVALID_OPERATION</code> is generated by
            <code class="function">glCopyNamedBufferSubData</code> if
            <em class="parameter"><code>readBuffer</code></em> or
            <em class="parameter"><code>writeBuffer</code></em> is not the name of an
            existing buffer object.
        </p>
        <p>
            <code class="constant">GL_INVALID_VALUE</code> is generated if any of
            <em class="parameter"><code>readOffset</code></em>,
            <em class="parameter"><code>writeOffset</code></em> or
            <em class="parameter"><code>size</code></em> is negative, if $readOffset + size$
            is greater than the size of the source buffer object (its value
            of <code class="constant">GL_BUFFER_SIZE</code>), or if $writeOffset +
            size$ is greater than the size of the destination buffer object.
        </p>
        <p>
            <code class="constant">GL_INVALID_VALUE</code> is generated if the source
            and destination are the same buffer object, and the ranges
            $[readOffset,readOffset+size)$ and
            $[writeOffset,writeOffset+size)$ overlap.
        </p>
        <p>
            <code class="constant">GL_INVALID_OPERATION</code> is generated if either
            the source or destination buffer object is mapped with
            <a class="citerefentry" href="glMapBufferRange"><span class="citerefentry"><span class="refentrytitle">glMapBufferRange</span></span></a>
            or
            <a class="citerefentry" href="glMapBuffer"><span class="citerefentry"><span class="refentrytitle">glMapBuffer</span></span></a>,
            unless they were mapped with the
            <code class="constant">GL_MAP_PERSISTENT</code> bit set in the
            <code class="function">glMapBufferRange</code>
            <em class="parameter"><code>access</code></em> flags.
        </p>
      </div>
      {$pipelinestall}{$examples}
      <div class="refsect1" id="versions">
        <h2>Version Support</h2>
        <div class="informaltable">
          <table style="border-collapse: collapse; border-top: 2px solid ; border-bottom: 2px solid ; border-left: 2px solid ; border-right: 2px solid ; ">
            <colgroup>
              <col style="text-align: left; "/>
              <col style="text-align: center; " class="firstvers"/>
              <col style="text-align: center; "/>
              <col style="text-align: center; "/>
              <col style="text-align: center; "/>
              <col style="text-align: center; "/>
              <col style="text-align: center; "/>
              <col style="text-align: center; "/>
              <col style="text-align: center; "/>
              <col style="text-align: center; "/>
              <col style="text-align: center; "/>
              <col style="text-align: center; "/>
              <col style="text-align: center; " class="lastvers"/>
            </colgroup>
            <thead>
              <tr>
                <th style="text-align: left; border-right: 2px solid ; ">

            </th>
                <th style="text-align: center; border-bottom: 2px solid ; " colspan="12">
                <span class="bold"><strong>OpenGL Version</strong></span>
            </th>
              </tr>
              <tr>
                <th style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>Function / Feature Name</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>2.0</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>2.1</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>3.0</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>3.1</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>3.2</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>3.3</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>4.0</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>4.1</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>4.2</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>4.3</strong></span>
            </th>
                <th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
                <span class="bold"><strong>4.4</strong></span>
            </th>
                <th style="text-align: center; border-bottom: 2px solid ; ">
                <span class="bold"><strong>4.5</strong></span>
            </th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
                  <code class="function">glCopyBufferSubData</code>
                </td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
                <td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
                <td style="text-align: center; border-bottom: 2px solid ; ">✔</td>
              </tr>
              <tr>
                <td style="text-align: left; border-right: 2px solid ; ">
                  <code class="function">glCopyNamedBufferSubData</code>
                </td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; border-right: 2px solid ; ">-</td>
                <td style="text-align: center; ">✔</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <div class="refsect1" id="seealso">
        <h2>See Also</h2>
        <p>
            <a class="citerefentry" href="glGenBuffers"><span class="citerefentry"><span class="refentrytitle">glGenBuffers</span></span></a>,
            <a class="citerefentry" href="glBindBuffer"><span class="citerefentry"><span class="refentrytitle">glBindBuffer</span></span></a>,
            <a class="citerefentry" href="glBufferData"><span class="citerefentry"><span class="refentrytitle">glBufferData</span></span></a>,
            <a class="citerefentry" href="glBufferSubData"><span class="citerefentry"><span class="refentrytitle">glBufferSubData</span></span></a>,
            <a class="citerefentry" href="glGetBufferSubData"><span class="citerefentry"><span class="refentrytitle">glGetBufferSubData</span></span></a>,
            <a class="citerefentry" href="glMapBuffer"><span class="citerefentry"><span class="refentrytitle">glMapBuffer</span></span></a>,
            <a class="citerefentry" href="glMapBufferRange"><span class="citerefentry"><span class="refentrytitle">glMapBufferRange</span></span></a>
        </p>
      </div>
      <div class="refsect1" id="Copyright">
        <h2>Copyright</h2>
        <p>
            Copyright © 2010-2014 Khronos Group.
            This material may be distributed subject to the terms and conditions set forth in
            the Open Publication License, v 1.0, 8 June 1999.
            <a class="link" href="https://opencontent.org/openpub/" target="_top">https://opencontent.org/openpub/</a>.
        </p>
      </div>
    </div>
